package KTV;

import java.util.ArrayList;
import java.util.Scanner;

public class KTV {

    public static ArrayList<String> songList = new ArrayList<>();
    public static Scanner scanner = new Scanner(System.in);

    public static void addSong() {
        System.out.print("请输入歌曲名：");
        String songName = scanner.nextLine();
        songList.add(songName);
        System.out.println("歌曲已添加成功，当前歌曲列表：" + songList);
    }

    public static void topsong() {
        System.out.println("请输入需要置顶的歌曲名：");
        String songName = scanner.nextLine();
        int index = songList.indexOf(songName);
        if (index != -1) {
            songList.remove(index);
            songList.add(0, songName);
            System.out.println("歌曲已置顶成功，当前歌曲列表为：" + songList);
        } else {
            System.out.println("该歌曲名不存在，无法置顶！！！");
        }
    }

    public static void moveupSong() {
        System.out.println("请输入需要前移的歌曲名：");
        String songName = scanner.nextLine();
        int index = songList.indexOf(songName);
        if (index != -1 && index > 0) {
            songList.remove(index);
            songList.add(index - 1, songName);
            System.out.println("歌曲已前移，当前歌曲列表为：" + songList);
        } else {
            System.out.println("该歌曲不不存在或已置顶，无法前移！！！");
        }

    }

    public static void showSong() {

        System.out.println("当前歌曲列表：" + songList);
    }

    public static void deleteSong() {
        System.out.println("请输入要删除的歌曲名：");
        String songName = scanner.nextLine();
        int index = songList.indexOf(songName);
        if (index != 1) {
            songList.remove(index);
            System.out.println("该歌曲已删除，当前歌曲列表：" + songList);
        } else {
            System.out.println("该歌曲不存在，无法删除！！！");
        }
    }

}


